/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package clasesbeans;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Enrique
 */
@Entity
@Table(name = "facturas")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Facturas.findAll", query = "SELECT f FROM Facturas f"),
    @NamedQuery(name = "Facturas.findByNroFactura", query = "SELECT f FROM Facturas f WHERE f.nroFactura = :nroFactura"),
    @NamedQuery(name = "Facturas.findByFechaEmision", query = "SELECT f FROM Facturas f WHERE f.fechaEmision = :fechaEmision"),
    @NamedQuery(name = "Facturas.findByFormaPago", query = "SELECT f FROM Facturas f WHERE f.formaPago = :formaPago"),
    @NamedQuery(name = "Facturas.findByDescuento", query = "SELECT f FROM Facturas f WHERE f.descuento = :descuento"),
    @NamedQuery(name = "Facturas.findBySubTotalGeneral", query = "SELECT f FROM Facturas f WHERE f.subTotalGeneral = :subTotalGeneral"),
    @NamedQuery(name = "Facturas.findByTotalIva", query = "SELECT f FROM Facturas f WHERE f.totalIva = :totalIva"),
    @NamedQuery(name = "Facturas.findByTotalDescuento", query = "SELECT f FROM Facturas f WHERE f.totalDescuento = :totalDescuento"),
    @NamedQuery(name = "Facturas.findByAnulado", query = "SELECT f FROM Facturas f WHERE f.anulado = :anulado"),
    @NamedQuery(name = "Facturas.findByTotalpago", query = "SELECT f FROM Facturas f WHERE f.totalpago = :totalpago")})
public class Facturas implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "nro_factura")
    private Integer nroFactura;
    @Basic(optional = false)
    @Column(name = "fecha_emision")
    @Temporal(TemporalType.DATE)
    private Date fechaEmision;
    @Column(name = "forma_pago")
    private String formaPago;
    @Column(name = "descuento")
    private Integer descuento;
    @Column(name = "sub_total_general")
    private Integer subTotalGeneral;
    @Column(name = "total_iva")
    private Integer totalIva;
    @Column(name = "total_descuento")
    private Integer totalDescuento;
    @Column(name = "anulado")
    private String anulado;
    @Column(name = "Total_pago")
    private Integer totalpago;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "nroFactura")
    private Collection<Ventas> ventasCollection;
    @JoinColumn(name = "id_usuario", referencedColumnName = "id_usuario")
    @ManyToOne
    private Usuarios idUsuario;
    @JoinColumn(name = "id_cliente", referencedColumnName = "id_cliente")
    @ManyToOne(optional = false)
    private Clientes idCliente;

    public Facturas() {
    }

    public Facturas(Integer nroFactura) {
        this.nroFactura = nroFactura;
    }

    public Facturas(Integer nroFactura, Date fechaEmision) {
        this.nroFactura = nroFactura;
        this.fechaEmision = fechaEmision;
    }

    public Integer getNroFactura() {
        return nroFactura;
    }

    public void setNroFactura(Integer nroFactura) {
        this.nroFactura = nroFactura;
    }

    public Date getFechaEmision() {
        return fechaEmision;
    }

    public void setFechaEmision(Date fechaEmision) {
        this.fechaEmision = fechaEmision;
    }

    public String getFormaPago() {
        return formaPago;
    }

    public void setFormaPago(String formaPago) {
        this.formaPago = formaPago;
    }

    public Integer getDescuento() {
        return descuento;
    }

    public void setDescuento(Integer descuento) {
        this.descuento = descuento;
    }

    public Integer getSubTotalGeneral() {
        return subTotalGeneral;
    }

    public void setSubTotalGeneral(Integer subTotalGeneral) {
        this.subTotalGeneral = subTotalGeneral;
    }

    public Integer getTotalIva() {
        return totalIva;
    }

    public void setTotalIva(Integer totalIva) {
        this.totalIva = totalIva;
    }

    public Integer getTotalDescuento() {
        return totalDescuento;
    }

    public void setTotalDescuento(Integer totalDescuento) {
        this.totalDescuento = totalDescuento;
    }

    public String getAnulado() {
        return anulado;
    }

    public void setAnulado(String anulado) {
        this.anulado = anulado;
    }

    public Integer getTotalpago() {
        return totalpago;
    }

    public void setTotalpago(Integer totalpago) {
        this.totalpago = totalpago;
    }

    @XmlTransient
    public Collection<Ventas> getVentasCollection() {
        return ventasCollection;
    }

    public void setVentasCollection(Collection<Ventas> ventasCollection) {
        this.ventasCollection = ventasCollection;
    }

    public Usuarios getIdUsuario() {
        return idUsuario;
    }

    public void setIdUsuario(Usuarios idUsuario) {
        this.idUsuario = idUsuario;
    }

    public Clientes getIdCliente() {
        return idCliente;
    }

    public void setIdCliente(Clientes idCliente) {
        this.idCliente = idCliente;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nroFactura != null ? nroFactura.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Facturas)) {
            return false;
        }
        Facturas other = (Facturas) object;
        if ((this.nroFactura == null && other.nroFactura != null) || (this.nroFactura != null && !this.nroFactura.equals(other.nroFactura))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "clasesbeans.Facturas[ nroFactura=" + nroFactura + " ]";
    }
    
}
